program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  pelement=^element;
  element=record
    next: pelement;
    value: integer;
  end;

procedure Add(var head: pelement; num: integer);
var
  tmp: pelement;
begin
  tmp:=head;
  new(head);
  head^.next:=tmp;
  head^.value:=num;
end;

procedure print(var head: pelement);
var
  current: pelement;
begin
  current:=head;
  while(current<>nil) do
  begin
    write(current^.value, '  ');
    current:=current^.next;
  end;
end;

procedure move(var head: pelement; n: integer);
var
  tmp1, tmp2, current, currentt: pelement;
  i, k1, k2, j: integer;
begin
  current:=head;
  currentt:=head;
  for i:=1 to n do
  begin

    if (i mod 2 =1) then
    begin
      for j:=1 to i-1 do
        current:=current^.next;
      tmp1:=current^.next;
      k1:=current^.value;
      for j:=1 to n-i do
      begin
        currentt:=currentt^.next;
      end;
      tmp2:=currentt^.next;
      k2:=currentt^.value;
      current^.next:=tmp2;
      currentt^.next:=tmp1;
      current^.value:=k2;
      currentt^.value:=k1;
    end;
    currentt:=head;
    current:=head;
  end;
end;

var
  n, i, num: integer;
  head: pelement;
  fin: textfile;
begin
  assignfile(fin, 'input.txt');
  reset(fin);
  head:=nil;
  readln(fin, n);
  for i:=1 to n do
  begin
    read(fin, num);
    add(head, num);
  end;
  print(head);
  writeln;
  move(head, n);
  print(head);
  readln;
end.
